import { defineStore } from 'pinia'
import { getNoReadCountApi, cleanNoReadApi, getNotifyMsgApi } from '@/api/message.js'

export const useMessageStore = defineStore('message', {
	state: () => {
		return {
			unreadCount: 0
		}
	},
	actions: {
		async getUnreadCount() {
			const count = await getNoReadCountApi()
			this.unreadCount = count
			return count
		},
		async cleanAllUnread() {
			const res = await cleanNoReadApi()
			this.unreadCount = 0
			return res
		},
		async getList(data) {
			const res = await getNotifyMsgApi(data)
			return res
		}
	}
})
